<?php

/**
 * Framework_Util_GetVars
 *
 * @author Application Support Group
 * @copyright University of Georgia
 * @package BAMF
 * @filesource
*/
/**
 * Framework_Util_GetVars
 *
 * A wrapper for the $_GET array.
 *
 * @author Application Support Group
 * @package BAMF
*/


class Framework_Util_GetVars extends Framework_Util_HttpRequestVars {

	public function __construct( $returns = Framework_Util_HttpRequestVars::RETURN_NULL ) {
		parent::__construct( $returns ) ;
	}

	protected function __get( $aVar ) {
		
		if (!array_key_exists($aVar, $_GET) || 
			(empty( $_GET[$aVar] ) && !is_numeric($_GET[$aVar]))) {

			return $this->returnValue ;

		} elseif( is_string( $_GET[ $aVar ] )) {
			return trim( $_GET[ $aVar ] ) ;
		}
		
		return $_GET[ $aVar ] ;

	}

	/**
	 * setReturnValue
         *
         * Alters the value returned when a _GET key is empty.
         *
	 * @param $aReturnVal the value to return.  Must evaluate to one of the class constants.
         * @return boolean True on success, False on failure.
	 */
	public function setReturnValue( $aReturnVal ) {

		$_output = false ;

		if( $aReturnVal === Framework_Util_HttpRequestVars::RETURN_NULL ) {
			$this->returnValue = Framework_Util_HttpRequestVars::RETURN_NULL ;
			$_output = true ;
		}

		if( $aReturnVal === Framework_Util_HttpRequestVars::RETURN_FALSE ) {
			$this->returnValue = Framework_Util_HttpRequestVars::RETURN_FALSE ;
			$_output = true ;
		}

		if( $aReturnVal === Framework_Util_HttpRequestVars::RETURN_EMPTYSTRING ) {
			$this->returnValue = Framework_Util_HttpRequestVars::RETURN_EMPTYSTRING ;
			$_output = true ;
		}

		if( $aReturnVal === Framework_Util_HttpRequestVars::RETURN_ZERO ) {
			$this->returnValue = Framework_Util_HttpRequestVars::RETURN_ZERO ;
			$_output = true ;
		}

		return $_output ;

	}
}

?>
